package com.mkyong.common.controller;

import com.mkyong.common.model.Movie;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/music")
public class MusicController {

    @RequestMapping(value = "/{name}", method = RequestMethod.GET)
    @ResponseBody
    public Movie getMusic(@PathVariable String name) {
        Movie movie = new Movie();
        movie.name = name;
        movie.year = "1989";
        return movie;

    }


    @RequestMapping(value = "/info")
    @ResponseBody
    public Object getMusicInfo(String name, String id, String sex, String email) {
        if (StringUtils.isEmpty(name)) {
            return "name 不能为空!";
        }
        Movie movie = new Movie();
        movie.name = name + ":" + sex;
        movie.year = id + ":" + email;
        return movie;

    }

}
